cmake_minimum_required(VERSION 3.6.0)
if (NOT ROOT_DIR)
    get_filename_component(ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}/../../" ABSOLUTE)
endif()
set(CURRENT_CMAKE_PATH ${CMAKE_CURRENT_LIST_DIR}/toolchain_common.cmake)
include(${CURRENT_CMAKE_PATH})

# set the other flags
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)

add_definitions(-DWIN32)

if (NOT COMPILER_ROOT)
    set(COMPILER_ROOT "/usr")
endif()

set(CMAKE_SYSROOT  "${COMPILER_ROOT}/x86_64-w64-mingw32")
set(CMAKE_C_COMPILER   "${COMPILER_ROOT}/bin/x86_64-w64-mingw32-gcc-posix")
set(CMAKE_CXX_COMPILER "${COMPILER_ROOT}/bin/x86_64-w64-mingw32-g++-posix")
set(CMAKE_AR           "${COMPILER_ROOT}/bin/x86_64-w64-mingw32-gcc-ar-posix")
set(CMAKE_RANLIB       "${COMPILER_ROOT}/bin/x86_64-w64-mingw32-gcc-ranlib-posix")
set(CMAKE_STRIP        "${COMPILER_ROOT}/bin/x86_64-w64-mingw32-strip")
set(CMAKE_SYSTEM_PROCESSOR "x86_64")
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_CROSSCOMPILING TRUE)
# set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})

message(INFO " C compiler is ${CMAKE_C_COMPILER}")
message(INFO " CXX compiler is ${CMAKE_CXX_COMPILER}")
get_filename_component(Qt6_ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}/../toolchains/gcc-mingw64-x86_64_w64-mingw32/Qt/6.8.0" ABSOLUTE)

# set(Qt6_DIR ${Qt6_ROOT_DIR}/mingw_64/lib/cmake/Qt6)
# set(Qt6Core_DIR ${Qt6_ROOT_DIR}/mingw_64/lib/cmake/Qt6Core)
# set(Qt6Gui_DIR ${Qt6_ROOT_DIR}/mingw_64/lib/cmake/Qt6Gui)

set(Qt6CoreTools_DIR ${Qt6_ROOT_DIR}/mingw_64/lib/cmake/Qt6CoreTools)
set(Qt6Core_DIR ${Qt6_ROOT_DIR}/mingw_64/lib/cmake/Qt6Core)
set(Qt6EntryPointPrivate_DIR ${Qt6_ROOT_DIR}/mingw_64/lib/cmake/Qt6EntryPointPrivate)
set(Qt6GuiTools_DIR ${Qt6_ROOT_DIR}/mingw_64/lib/cmake/Qt6GuiTools)
set(Qt6Gui_DIR ${Qt6_ROOT_DIR}/mingw_64/lib/cmake/Qt6Gui)
set(Qt6Network_DIR ${Qt6_ROOT_DIR}/mingw_64/lib/cmake/Qt6Network)
set(Qt6OpenGL_DIR ${Qt6_ROOT_DIR}/mingw_64/lib/cmake/Qt6OpenGL)
set(Qt6QmlCompilerPlusPrivate_DIR Qt6QmlCompilerPlusPrivate_DIR-NOTFOUND)
set(Qt6QmlIntegration_DIR ${Qt6_ROOT_DIR}/mingw_64/lib/cmake/Qt6QmlIntegration)
set(Qt6QmlMeta_DIR ${Qt6_ROOT_DIR}/mingw_64/lib/cmake/Qt6QmlMeta)
set(Qt6QmlModels_DIR ${Qt6_ROOT_DIR}/mingw_64/lib/cmake/Qt6QmlModels)
set(Qt6QmlTools_DIR ${Qt6_ROOT_DIR}/mingw_64/lib/cmake/Qt6QmlTools)
set(Qt6QmlWorkerScript_DIR ${Qt6_ROOT_DIR}/mingw_64/lib/cmake/Qt6QmlWorkerScript)
set(Qt6Qml_DIR ${Qt6_ROOT_DIR}/mingw_64/lib/cmake/Qt6Qml)
set(Qt6QuickTools_DIR ${Qt6_ROOT_DIR}/mingw_64/lib/cmake/Qt6QuickTools)
set(Qt6QuickWidgets_DIR ${Qt6_ROOT_DIR}/mingw_64/lib/cmake/Qt6QuickWidgets)
set(Qt6Quick_DIR ${Qt6_ROOT_DIR}/mingw_64/lib/cmake/Qt6Quick)
set(Qt6WebChannel_DIR ${Qt6_ROOT_DIR}/mingw_64/lib/cmake/Qt6WebChannel)
set(Qt6WidgetsTools_DIR ${Qt6_ROOT_DIR}/mingw_64/lib/cmake/Qt6WidgetsTools)
set(Qt6Widgets_DIR ${Qt6_ROOT_DIR}/mingw_64/lib/cmake/Qt6Widgets)
set(Qt6ZlibPrivate_DIR ${Qt6_ROOT_DIR}/mingw_64/lib/cmake/Qt6ZlibPrivate)
set(Qt6_DIR ${Qt6_ROOT_DIR}/mingw_64/lib/cmake/Qt6)
set(CMAKE_PREFIX_PATH ${Qt6_ROOT_DIR}/mingw_64)